package com.ym521.simp

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.google.gson.Gson
import com.ym521.logdog.LogDog

class MainActivity : AppCompatActivity() {

    private val TAG = "MainActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        LogDog.debug(TAG, "onCreate")
        LogDog.builder.logShowMethodEnable(true, 3)
        LogDog.debug("CS", "开始测试第一例  debug")
        LogDog.info("CS", "开始测试第一例  info")
        LogDog.warn("CS", "开始测试第一例  warn")
        LogDog.error("CS", "开始测试第一例  error")
        val intAray = mutableListOf(1, 2, 3, 4, 5, 6, 7, 8, 9)
        LogDog.info("SZ", intAray)
        val dataList = mutableListOf(
            TestData("1001", true, 100, 180),
            TestData("1002", false, 20, 170),
            TestData("1003", true, 30, 185)
        )
        LogDog.debugf(
            "1003",
            "%s (Optional) Whether to show thread info or %s not. Default true",
            "11111",
            dataList
        )
        setLog()

        Thread {
            for (i in 0..5) {
                LogDog.debug(
                    "Thread_1",
                    "(Optional) Whether to show thread info or not. Default true"
                )
                LogDog.error("Thread_1", "(Optional) How many method line to show. Default 2")
                LogDog.info(
                    "Thread_1",
                    "(Optional) Skips some method invokes in stack trace. Default 5"
                )
            }
        }.start()
        Thread {
            for (i in 0..5) {
                LogDog.debug(
                    "Thread_2",
                    "(Optional) Whether to show thread info or not. Default true"
                )
                LogDog.error("Thread_2", "(Optional) How many method line to show. Default 2")
                LogDog.info(
                    "Thread_2",
                    "(Optional) Skips some method invokes in stack trace. Default 5"
                )
            }
        }.start()

        findViewById<View>(R.id.tvDedug).postDelayed({
            startActivity(Intent(this, MainActivity2::class.java))
            finish()
        }, 10 * 1000)

    }

    private fun setLog() {
        initView()
    }

    private fun initConfig() {
        LogDog.debug("(Optional) Whether to show thread info or not. Default true")
        LogDog.error("(Optional) How many method line to show. Default 2")
        LogDog.info("(Optional) Skips some method invokes in stack trace. Default 5")
    }

    private fun initView() {
        LogDog.debug("(Optional) Whether to show thread info or not. Default true")
        LogDog.info("(Optional) How many method line to show. Default 2")
        LogDog.warn("(Optional) Skips some method invokes in stack trace. Default 5")
        initConfig()
    }

    override fun onStart() {
        super.onStart()
        LogDog.debug(TAG, "onStart")
    }

    override fun onResume() {
        super.onResume()
        LogDog.debug(TAG, "onResume")
    }

    override fun onPause() {
        super.onPause()
        LogDog.debug(TAG, "onPause")
    }

    override fun onStop() {
        super.onStop()
        LogDog.debug(TAG, "onStop")
    }

    override fun onDestroy() {
        super.onDestroy()
        LogDog.debug(TAG, "onDestroy")
    }


}